//
//  HomeMeetingFromModel_Two.m
//  Gxj
//
//  Created by tcwx on 2017/9/27.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "HomeMeetingFromModel_Two.h"

NSString *const kTextModel_TwoMeetingid      = @"meetingid";
NSString *const kTextModel_TwoUserid         = @"userid";
NSString *const kTextModel_TwoHead_img       = @"head_img";
NSString *const kTextModel_twoNickname       = @"nickname";
NSString *const kTextModel_twoIndustry       = @"industryid";
NSString *const kTextModel_TwoInfo           = @"info";
NSString *const kTextModel_TwoImgsrc         = @"imgsrc";
NSString *const kTextModel_TwoCreate_date    = @"create_date";
NSString *const kTextModel_TwoStart_date     = @"start_date";
NSString *const kTextModel_TwoPosition       = @"position";
NSString *const kTextModel_TwoTitle          = @"title";

@implementation HomeMeetingFromModel_Two

@synthesize meetingid   = _meetingid;
@synthesize userid      = _userid;
@synthesize head_img    = _head_img;
@synthesize nickname    = _nickname;
@synthesize industryid  = _industryid;
@synthesize info        = _info;
@synthesize imgsrc      = _imgsrc;
@synthesize create_date = _create_date;
@synthesize start_date  = _start_date;
@synthesize position    = _position;
@synthesize title       = _title;

// 处理model套model 或者array套dictionary、array
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

// 初始化
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    if (self && [dict isKindOfClass:[NSDictionary class]])
    {
        _meetingid   = [self checkNilObjectForKey:kTextModel_TwoMeetingid   fromDictionary:dict];
        _userid      = [self checkNilObjectForKey:kTextModel_TwoUserid      fromDictionary:dict];
        _head_img    = [self checkNilObjectForKey:kTextModel_TwoHead_img    fromDictionary:dict];
        _nickname    = [self checkNilObjectForKey:kTextModel_twoNickname    fromDictionary:dict];
        _industryid  = [self checkNilObjectForKey:kTextModel_twoIndustry    fromDictionary:dict];
        _info        = [self checkNilObjectForKey:kTextModel_TwoInfo        fromDictionary:dict];
        _imgsrc      = [self checkNilObjectForKey:kTextModel_TwoImgsrc      fromDictionary:dict];
        _create_date = [self checkNilObjectForKey:kTextModel_TwoCreate_date fromDictionary:dict];
        _start_date  = [self checkNilObjectForKey:kTextModel_TwoStart_date  fromDictionary:dict];
        _position    = [self checkNilObjectForKey:kTextModel_TwoPosition    fromDictionary:dict];
        _title       = [self checkNilObjectForKey:kTextModel_TwoTitle       fromDictionary:dict];
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:_meetingid    forKey:kTextModel_TwoMeetingid];
    [mutableDict setValue:_userid       forKey:kTextModel_TwoUserid];
    [mutableDict setValue:_head_img     forKey:kTextModel_TwoHead_img];
    [mutableDict setValue:_nickname     forKey:kTextModel_twoNickname];
    [mutableDict setValue:_industryid   forKey:kTextModel_twoIndustry];
    [mutableDict setValue:_info         forKey:kTextModel_TwoInfo];
    [mutableDict setValue:_imgsrc       forKey:kTextModel_TwoImgsrc];
    [mutableDict setValue:_create_date  forKey:kTextModel_TwoCreate_date];
    [mutableDict setValue:_start_date   forKey:kTextModel_TwoStart_date];
    [mutableDict setValue:_position     forKey:kTextModel_TwoPosition];
    [mutableDict setValue:_title        forKey:kTextModel_TwoTitle];
    
    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (id)checkNilObjectForKey:(id)key fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:key];
    return [object isKindOfClass:[NSNull class]] ? nil : object;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@",[self dictionaryRepresentation]];
}


@end
